<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
	<title>编辑写手 </title>
</head>
<body>
<div class="layui-fluid">
	<div class="layui-row">
		<form class="layui-form form form-horizontal" id="form-admin-add" action="#" th:action="@{/partner/moduleLeader/edit}" >
<!--			<input type="hidden" name="save" value="true"/>-->
			<input type="hidden" th:value="${user.id}" name="id">
			<div class="layui-form-item" >
			<label for="username" class="layui-form-label">
				<span class="x-red">*</span>账号
			</label>
			<div class="layui-input-inline">
				<input type="text" id="username" name="username" th:value="${user.username}"
					   autocomplete="off" class="layui-input">
			</div>
		</div>
			<div class="layui-form-item">
				<label class="layui-form-label">
					昵称
				</label>
				<div class="layui-input-inline">
					<input type="text" id="nickname" name="nickname" th:value="${user.nickname}"
						   autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">
					<span class="x-red">*</span>性别
				</label>
				<div class="layui-input-inline">
					<input name="sexType" th:checked="${user.sexType eq c.key}" type="radio"
						   th:each="c:${sexType}"  th:value="${c.key}" th:text="${c.value}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">
            手机
        </label>
        <div class="layui-input-inline">
            <input type="text" id="tel" name="tel"  lay-verify="phone" th:value="${user.tel}"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">
            邮箱
        </label>
        <div class="layui-input-inline">
            <input type="text" id="email" name="email" lay-verify="email" th:value="${user.email}"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">
        </label>
        <button  class="layui-btn" id="subbtn" type="submit">
            修改
        </button>
    </div>
</form>
</div>
</div>

<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs"></div>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/jquery.validate.js}" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/validate-methods.js}" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/messages_zh.js}"  src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
	$(function(){
		layui.use(['form', 'layer'],
				function() {
					$ = layui.jquery;
					var form = layui.form,
							layer = layui.layer;
				});

		$("#form-admin-add").validate({
			rules:{
				username:{
					required:true,
					// minlength:4,
					maxlength:16
				},
				password:{
					required:true,
				},
				password2:{
					required:true,
					equalTo: "#password"
				},
				sexType:{
					required:true,
				},
				tel:{
					isPhone:true,
				},
				email:{
					email:true,
				},
			},
			onkeyup:false,
			success:"valid",
			submitHandler:function(form){
				$.lock();
				$(form).ajaxSubmit({
					type: 'post',
					url: "/partner/moduleLeader/edit",
					success: function(data){
						console.log(data);
						if(data.code == "1") {
							//禁止重复提交
							// $('#subbtn').attr("type", "button");
							selfmsg('修改成功!',1,function(){
								window.location.reload();
								var index = parent.layer.getFrameIndex(window.name);
								parent.location.reload();
								parent.layer.close(index);
							});
						}else{
							layer.msg('修改失败!');
							$.unlock();
						}
					},
					error: function(XmlHttpRequest, textStatus, errorThrown){
						layer.msg('error!');
						$.unlock();
					}
				});

			}
		});
	});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>